import cv2 as cv

import numpy as np 

orl = cv.imread("/home/heron/Desktop/linux_notes/python/img/pic001.png")


#读取一个单通道
img = orl[:,:,0]

# 获取图片宽，高
r,c =img.shape

# 生成随机秘钥
key = np.random.randint(0,256,size=[r,c],dtype = np.uint8)
cv.imshow("key",key)
cv.waitKey()


# 加密
encryption = cv.bitwise_xor(img,key)
cv.imshow("encryption",encryption)
cv.waitKey()

# 解密
decryption = cv.bitwise_xor(encryption,key)

cv.imshow("de",decryption)
cv.waitKey()
cv.destroyAllWindows()
